<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'delcarseries.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script>
		function showSeries(bid){
			$("#"+bid).toggle();
		    		$.getJSON("GetCarSeriesByBrandIdAction",{"brandId":bid},function(data){
		    			if(data.carseries.length>0){
		    				$("#"+bid).html("");
		    				$.each(data.carseries,function(index,value){
		    					$("#"+bid).append("<div id='child"+value.seriesId+"'></div>");
				    			$("#child"+value.seriesId+"").append(value.seriesName);
				    			$("#child"+value.seriesId+"").append("<a href='javascript:void(0);' onclick='deleteSeries("+value.seriesId+")'><img style='padding-left: 5px;' width='10px' height='10px' src='img/d2.gif'></a>");
				 			});
		    			}else{
		    				$("#"+bid).html("该品牌还没车型");
		    			}
			    	});
		}
	function deleteSeries(sid){
			if(window.confirm("确定要删除么?")){
				$.post("deleteBrandSeriesAction",{"brandId":0,"seriesId":sid},function(data){
					if(data=="success"){
						alert("删除成功");
						$("#child"+sid+"").html("");
					}else{
						alert("删除失败");
					}
				} ); 
			}
	}
	
	function deleteBrand(bid){
		if(window.confirm("确定要删除么?")){
				$.post("deleteBrandSeriesAction",{"brandId":bid,"seriesId":0},function(data){
					if(data=="success"){
						alert("删除成功");
						$("#p"+bid).html("");
					}else{
						alert("删除失败");
					}
				} ); 
			}
	}
	</script>
  </head>
  <body>
    		<div align="center"><h2>删除品牌系列</h2></div>
			<div style="width: 300px; height: 1300px; margin-left: 500px;">
					<c:forEach items="${brands}" var="brand">
							<div id="p${brand.brandsId}">
								<ul>
									<li><a href="javascript:void(0);" onclick="showSeries(${brand.brandsId})">${brand.brandsName}</a><a href="javascript:void(0);" onclick="deleteBrand(${brand.brandsId})"><img style="padding-left: 5px;" width="10px" height="10px" src="img/d1.gif"></a></li>
									<div id="${brand.brandsId}" style="display: none; padding-left: 8px;"></div>
								</ul>
							</div>
					</c:forEach>
			  
       	    </div>
  </body>
</html>
